import { Type } from 'class-transformer';
import {
  IsNotEmpty,
  IsNumber,
  IsOptional,
  IsString,
  ValidateNested,
} from 'class-validator';

export class PageDto {
  @IsNumber()
  @IsNotEmpty()
  pageNo: number;

  @IsNumber()
  @IsNotEmpty()
  pageSize: number;
}

export class QueryNewDto {
  @IsOptional()
  id: number;

  @IsString()
  @IsOptional()
  title: string;

  @IsString()
  @IsOptional()
  desc: string;

  @IsOptional()
  categoryId: number;

  @IsOptional()
  goodsId: number;
}

export class ListNewDto {
  @ValidateNested()
  @Type(() => PageDto)
  pageDto: PageDto;

  @ValidateNested()
  @Type(() => QueryNewDto)
  @IsOptional()
  queryDto: QueryNewDto;
}
